<form action="" method="post">
	称&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;呼：<input type="text" name="named" id="named"><br><br>
	手机号码：<input type="text" name="mobile" id="mobile"><br><br>
	需求信息：<input type="text" name="demand" id="demand"><br><br>
	<button  type="button" onclick="return subscribe();" >立即预约</button>
</form>
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo base_url('publics/home');?>/layer/layer.js"></script>
<script type="text/javascript">
function subscribe(){
    var valData = {
      'pro_id'    :  <?php echo $_GET['pid'];?>,
      'cate_id'   :  <?php echo $_GET['cid'];?>,
      'named'     :  $('#named').val(),
      'mobile'    :  $('#mobile').val(),
      'demand'    :  $('#demand').val()
    }
    $.ajax({
        type : 'POST',
        url  : '<?php echo base_url('subscribe/subscribe');?>',
        data : valData,
        success:function(msg){
            var json = eval('('+msg+')');
            if(json.err == 0 ){
              alert('预约成功');      
              var index = parent.layer.getFrameIndex(window.name);
              parent.layer.close(index); //再执行关闭   
            }
            if(json.err > 0){
              layer.msg(json.msg);
            }
        }
    });
}
</script>